﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Imgalib.Utility;
using System.Collections;
using System.Globalization;
using SocialShare.BusinessEntities;
using System.Data;
using System.IO;

namespace SocialShare.Web
{
    public partial class utility_demo : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                CountryDropDownList1.DataBind();
                StateDropDownList1.DataBind();
                //StringWriter sw = new StringWriter();
                //HttpContext.Current.Server.Execute("~/signin.aspx",sw,true);
                //txtXML.Text = sw.ToString();
                
            }
        }

        protected void btnSpell_Click(object sender, EventArgs e)
        {
            litSpell.Text= NumberToWords.SpellNumber(Convert.ToDecimal(txtSpell.Text.Trim()));
        }

        protected void btnXmlTest_Click(object sender, EventArgs e)
        {
            SocialShare.DAL.Facades.BlogFacade facede = new DAL.Facades.BlogFacade();
            List<BlogPost> blogs=facede.GetAllActiveBlogPosts(0, 10);
            String XML = XmlConverter.ConvertListToXML<BlogPost>(blogs);
            txtXML.Text = XML;
            //CsvUtility.ExportListToCSV<BlogPost>(blogs, ",");

            DataTable dtTemp = new DataTable();
            dtTemp.Columns.Add("ID");
            dtTemp.Columns.Add("Name");
            dtTemp.Columns.Add("Email");
            dtTemp.Columns.Add("DOB");

            for (Int32 index = 0; index < 50; index++)
            {
                DataRow dr=dtTemp.NewRow();
                dr[0]=index.ToString();
                dr[1]="Name"+index;
                dr[2]=index+"_Name@yahoo.com";
                dr[3]=DateTime.Now.AddDays(index).ToShortDateString();
                dtTemp.Rows.Add(dr);
            }

            CsvUtility.ExportDataTableToCSV(dtTemp, ",");

            
        }
    }
}